<template>
  <div class="history-card">
    <el-row :gutter="10" style="align-items: center;">
      <el-col :span="6">
        <div class="video-thumbnail" @click="sunvdeo()">
        <el-image class="img"
            style="width: 100%;  border-radius: 8px;"
            :src="'http://localhost:9091/images/video/' + videoh.imgurl"
            fit="cover"
        ></el-image>
        <div class="overlay">
          <i class="el-icon-video-play play-icon"></i>
        </div>
        </div>
      </el-col>
      <el-col :span="18">
        <div class="video-details">
          <h3 class="video-title">{{ videoh.sername }}</h3>
          <div class="video-info">
            <span class="info-item"><strong>作者：</strong>{{ videoh.uname }}</span>
            <span class="info-item"><strong>分区：</strong>{{ videoh.category }}</span>
            <span class="info-item"><strong>发布于：</strong>{{ formattedDateTime }}</span>
            <span class="info-item"><strong>播放：</strong>{{ videoh.vcount }}</span>
            <span class="info-item"><strong>弹幕：</strong> 0</span>
            <span class="info-item"><strong>观看于：</strong> {{ formattedWatchTime }}</span>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import {hisadd,hislist} from "@/api";
export default {
  data() {
    return {
     video: {},
      url:''
    };
  },
  props: {
    videoh: {
      type: Object,
      required: true
    },
    callback: {
      type: Function
    }
  },
  computed: {
    formattedWatchTime() {
      const date = new Date(this.videoh.wachtime);
      return date.toLocaleString(); // 你可以根据需要调整格式
    },
    formattedDateTime() {
      const date = new Date(this.videoh.datetime);
      return date.toLocaleString(); // 你可以根据需要调整格式
    }
  },
  methods: {
    sunvdeo() {
     this.callback(this.videoh);

    }
  }
};
</script>

<style scoped lang="less">
.history-card {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  padding: 16px;
  margin-bottom: 16px;
  transition: box-shadow 0.3s ease;

  &:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  }

  .video-details {
    margin-left: 16px;

    .video-title {
      font-size: 1em;
      font-weight: bold;
      margin-bottom: 8px;
      color: #333;
    }

    .video-info {
      display: flex;
      flex-direction: column;
      color: #606060;
      font-size: 0.9em;

      .info-item {
        margin-bottom: 4px;
      }
    }
  }
}


.video-thumbnail {
  display: inline-block;
  position: relative;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  overflow: hidden;
  width: 100%; /* 确保图片宽度占满整个卡片 */

}

.video-thumbnail img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.video-thumbnail:hover img {
  transform: scale(1.05);
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.video-thumbnail:hover .overlay {
  opacity: 1;
}

.play-icon {
  font-size: 48px;
  color: #fff;
}
</style>
